import { remove } from "nprogress";
import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    token: "", // 保存token字符串
    illustrateValue: "", //不通过 认证说明 输入框的值
    orderData: null,
    isNewMessage:false,
    phoneNumber:"",
    avatar:"",
    nickName:"111",
    email:"",
    userName:""
  },
  getters: {},
  mutations: {
    /** 保存token */
    saveToken(state, payload) {
      state.token = payload.token;

      if (payload.checked) {
        localStorage.setItem("token", payload.token);
      } else {
        sessionStorage.setItem("token", payload.token);
      }
    },
    // 保存自行建单数据
    saveCreateOrder(state, data) {
      state.orderData = data;
      localStorage.setItem("orderData", data);
    },
    saveIllustrateValue(state, illustrateValue) {
      state.illustrateValue = illustrateValue;
    },
    deleteToken(state) {
      (state.token = ""), sessionStorage.removeItem("token");
      localStorage.removeItem("token");
    },
    saveUserInfo(state,payload){
      state.phoneNumber = payload.phoneNumber;
      state.avatar = payload.avatar;
      state.nickName = payload.nickName;
      state.email = payload.email;
      state.userName=payload.userName
    }
  },
  actions: {},
  modules: {},
});
